import axios from 'axios';
import { API_ROOT } from '../config'


export default {

    /*
     * 登录
     * */
    login: function(data, cb, errorCb) {
        axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';

        console.log("api==>user==>login", data)
        axios.post(API_ROOT + '/login', { phone: data.phone, password: data.password }).then(function(res) {
            console.log("userRes", res.data.Data)
            var status = res.data.Status
            if (status) {
                console.log(res.data.Data)
                setTimeout(function() {
                    cb(res.data.Data)
                }, 300)

            } else {
                errorCb(res.data)
            }
        })
        .catch(function(error) {
            console.log(error);
        });;

    }
};